package com.daftmaster.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.daftmaster.entity.DeptEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Daft_V
 * @date 2022/3/24 10:13
 */
@Mapper
public interface DeptMapper extends BaseMapper<DeptEntity> {
    /**
     * 按照dept_level长度查询
     *
     * @param length 长度
     * @return 返回json字符串
     */
    @Select("select * from t_dept where length(dept_level)=#{length}")
    List<DeptEntity> queryDeptByLevelLength(@Param("length") int length);

    /**
     * 按照dept_level长度和delt_level查询下级组织机构
     *
     * @param length     长度
     * @param dept_level 组织分级
     * @return 返回json字符串
     */
    @Select("select * from t_dept where length(dept_level)=#{length} and dept_level like #{dept_level}")
    List<DeptEntity> queryDeptByLevelLengthAndLevel(@Param("length") int length, @Param("dept_level") String dept_level);
}
